package Demo1;

import com.sun.source.tree.Tree;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 34255
 * Date: 2024-07-31
 * Time: 12:11
 */
class Node {
    int val;
    Node next;
    Node random;

    public Node(int val) {
        this.val = val;
        this.next = null;
        this.random = null;
    }
}
public class Test {
    public int singleNumber(int[] nums) {
        Set<Integer> set = new HashSet<>();
        //判断集合里是否包含该数字
        for(int i = 0;i < nums.length;i++){
            if(set.contains(nums[i])){
                set.remove(nums[i]);
            }else{
                set.add(nums[i]);
            }
        }

        for (int i = 0; i < nums.length; i++) {
            if(set.contains(nums[i])){
                return nums[i];
            }
        }
        return -1;
    }

    public Node copyRandomList(Node head) {

        //1.遍历原链表，如果节点不为空，创建出新节点，把原链表节点值赋给新节点
        HashMap<Node,Node> map = new HashMap<>();
        Node cur = head;
        while(cur != null){
            Node newNode = new Node(cur.val);
            map.put(cur,newNode);
            cur = cur.next;
        }

        //2.将新链表串联起来
        cur = head;
        while(cur != null){
            map.get(cur).next = map.get(cur.next);
            map.get(cur).random = map.get(cur.random);
        }
        return map.get(head);
    }

    public int numJewelsInStones(String jewels, String stones) {
        HashSet<Character> set = new HashSet<>();

        int count = 0;
        //把宝石放入集合
        for(int i = 0;i < jewels.length();i++){
            set.add(jewels.charAt(i));
        }

        //遍历石头，判断是否存在于宝石中
        for (int i = 0; i < stones.length(); i++) {
            if(set.contains(stones.charAt(i))){
                count++;
            }
        }
        return count;
    }

    public static void findBad(){
        Scanner scanner = new Scanner(System.in);
        String str1 = scanner.nextLine();
        String str2 = scanner.nextLine();

        str1 = str1.toUpperCase();
        str2 = str2.toUpperCase();
        HashSet<Character> set = new HashSet<>();
        for (int i = 0; i < str2.length(); i++) {
            set.add(str2.charAt(i));
        }

        HashSet<Character> ret = new HashSet<>();
        for (int i = 0; i < str1.length(); i++) {
            if(!set.contains(str1.charAt(i)) && !ret.contains(str1.charAt(i))){
                ret.add(str1.charAt(i));
                System.out.println(str1.charAt(i));
            }
        }
    }

//    public List<String> topKFrequent(String[] words, int k) {
//        TreeMap<String,Integer > map = new TreeMap<>();
////        TreeSet<Map.Entry<String,Integer>> set = new TreeSet<>();
//
//        //统计每个单词个数
//        for (String s:words){
//            if(!map.containsKey(s)) {
//                map.put(s,1);
//            }else{
//                int val = map.get(s);
//                map.put(s,val + 1);
//            }
//        }
//
//        Set<Map.Entry<String,Integer>> set = map.entrySet();
//        ArrayList<Map.Entry<String,Integer>> arr = new ArrayList<>(set);
//        PriorityQueue<Map.Entry<String,Integer>> que = new PriorityQueue<>();
//        //创建小根堆
//        for (int i = 0; i < arr.size(); i++) {
//            if(i < k){
//                arr.
//            }else{
//
//            }
//        }
//    }
    public static void main(String[] args) {
        findBad();
    }
}
